import winston from 'winston'
import { Request, Response, NextFunction } from 'express'
import { logger } from '../utils/logger'

// Express中间件：记录HTTP请求日志
export const httpLogger = (req: Request, res: Response, next: NextFunction) => {
  // 记录请求信息
  logger.info('请求地址', {
    method: req.method,
    url: req.url,
    ip: req.ip,
    headers: req.headers,
    body: req.body,
    query: req.query,
    timestamp: new Date().toISOString(),
  })

  next()
}
